class Solution {
    public:
        vector<string> ret;
        string path;
        vector<string> letterCasePermutation(string s) {
            dfs(0,s);
            return ret;
        }
        void dfs(int pos,string s){
            if( pos == s.size()){
                ret.push_back(path);
                return;
            }
            if(isalpha(s[pos])){
                path+=toupper(s[pos]);
                dfs(pos+1,s);
                path.pop_back();
                path+=tolower(s[pos]);
                dfs(pos+1,s);
                path.pop_back();
            }else{
                path+=s[pos];
                dfs(pos+1,s);
                path.pop_back();
            }
        }
    };